package com.bigevent.validation;

import com.bigevent.anno.State;
import jakarta.validation.ConstraintValidator;
import jakarta.validation.ConstraintValidatorContext;

// ConstraintValidator<给哪一个注解提供校验规则,校验的数据类型>
public class StateValidation implements ConstraintValidator<State,String> {
    /**
     * @param value:将来要校验的数据
     * @param constraintValidatorContext:约束校验器上下文
     * @return boolean true 校验通过，false 校验不通过
     */
    @Override
    public boolean isValid(String value, ConstraintValidatorContext constraintValidatorContext) {
        //校验规则
        if(value.equals("已发布") || value.equals("草稿")){
            return true;
        }
        else{
            return false;
        }
    }
}
